package user.blog.post.comments;

import java.util.Properties;

import database.UIDManger;

public class Comment {
	private Properties comment;
	
	public Comment(String text, String author, String sessionId) throws Exception {
		comment = new Properties();
		setProperty(CommentFlags.CID, UIDManger.getValidCommentID());
		setProperty(CommentFlags.SESSIONID, sessionId);
		setProperty(CommentFlags.AUTHOR, author);
		setProperty(CommentFlags.TEXT, text);
	}
	
	public Comment(String text, String author, String cid, String sessionId) {
		comment = new Properties();
		setProperty(CommentFlags.CID, cid);
		setProperty(CommentFlags.SESSIONID, sessionId);
		setProperty(CommentFlags.AUTHOR, author);
		setProperty(CommentFlags.TEXT, text);
	}
	
	public String setProperty(CommentFlags flag, String value) {
		comment.setProperty(flag.getFlag(), value);
		return comment.getProperty(CommentFlags.CID.getFlag());
	}
	
	public String getProperty(CommentFlags flag) {
		return comment.getProperty(flag.getFlag());
	}
	
	public Properties getComment() {
		return comment;
	}
}
